// 找到当前路由
export const findRouteByPath = (routes: any[], key: string): any => {
  for (const route of routes) {
    if (route.path === key) return route;
    if (route.children) {
      const child = findRouteByPath(route.children, key);
      if (child) return child;
    }
  }
  return null;
};

// // 获取树节点的第一个最底层叶子节点
// export const findFirstBottomNode = (tree: Record<string, any>[]) => {
//   let node: any = null;
//   tree.forEach((item) => {
//     if (node) return false;
//     if (item.children && item.children.length > 0) {
//       const newNode = findFirstBottomNode(item.children);
//       if (newNode) {
//         node = newNode;
//       }
//     } else {
//       node = item;
//     }
//   });

//   return node;
// };

// console.log(findFirstBottomNode(data));
